/*================================================================
*   Copyright (C) 2021 IMVS Ltd. All rights reserved.
*   
*   Filename   ：main.c
*   Creator    ：Chase Wu
*   Create Date：2021/05/31
*   Description：
*
================================================================*/


#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <unistd.h>

#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

#include "log.h"
#include "dispatch.h"

int main(int argc, char* argv[])
{
	int32_t ret;
	struct dispatch* pdispatch;
	struct uconfig *puconfig;

	ret = create_init_dispatch(&pdispatch);
	if(ret < 0){
		DBG(DBG_ERR, "create init dispatch error\n");
		return ret;
	}

    puconfig = pdispatch->puconfig;
    puconfig->input_config_file = argv[1];
    puconfig->op->load(puconfig);
    puconfig->op->show(puconfig);
	ret = pdispatch->op->start(pdispatch);
	if(ret < 0){
		DBG(DBG_ERR, "dispatch start error\n");
		return ret;
	}

	while(1){
		sleep(1);
	}
	pdispatch->op->stop(pdispatch);
	release_destroy_dispatch(pdispatch);
	return 0;
}
